Repository navigation
Conversation
…e context Wire selection capture in the v2 code viewer into the existing agent prompt pipeline: highlight a region and send it — with its file path and line range — to the active/open agent (or a new session if none is open). Adds getSelection() on the v2 CodeEditorAdapter, a useSendSelectionToAgent hook (bounded snippets, supersede guard, toast-on-error keep-for-retry), and the FilePane/ViewProps wiring that mounts a "Send selection to agent" affordance in CodeView. Reuses formatAgentPromptWithFileContext as the shared formatter seam.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Ready to review this PR? Stage has broken it down into 7 individual chapters for you: Chapters generated by Stage for commit d1877bc on Jun 24, 2026 2:07pm UTC. |
…ncile edge ParadevAI#4, debounce selection handler - Extract the edge-ParadevAI#5 supersede guard into a pure isStillCurrent(token, currentToken) and unit-test both branches (renderHook unavailable in this test harness). Hook now calls it instead of an inline ref compare. - Make edge ParadevAI#4 refuse-only explicit: extract shouldRefuseSelection() (null/ empty + defensive empty-path / non-finite-line guard) and unit-test it; the v2 CodeView host always has a resolvable ViewProps.filePath, so the text-only fallback is unreachable in PR1 and deferred to PR2. - Debounce CodeEditor's onSelectionChange so selection-derived UI recomputes on selection settle (120ms) instead of every CodeMirror selectionSet, mirroring the DiffPane sibling's onLineSelectionEnd cadence.
…t is available
CHANGE 1 (no-agent feedback): when a valid selection has no resolvable
target (no live terminal agent AND no agent config — resolver yields
null), send() now surfaces a clear, actionable sonner toast ('No agent
available to send to. Start an agent in this workspace, or add one in
Settings -> Agents.') instead of the misleading 'couldn't start a new
session' error. The decision is a pure classifier resolveSendOutcome()
mapping (region, target) -> 'dispatch' | 'no-agent' | 'no-selection',
unit-tested without a renderHook harness.
CHANGE 2 (Mod-Enter shortcut): bind Cmd/Ctrl+Enter in the v2 CodeEditor
keymap (alongside Mod-s) to trigger the same default-target send as the
button. onSendSelection is threaded CodeView -> CodeEditor and held in a
ref (mirrors onSelectionChangeRef). The keymap entry reuses the adapter's
captureSelection as the selection-presence gate: consumes the chord
(returns true) only when a non-empty selection exists, else returns false
so Mod-Enter falls through to default editor behavior (no stray newline).
The button stays; the shortcut is an addition.
Relax the AgentCommentComposer submit gate so a comment is no longer required — ⌘/Ctrl+↵ now sends just the selected line reference. The shared prompt formatter emits the bare anchor (no dangling ': ') when the comment is empty.
…d host pr-review: the per-host pointerup registry keyed dedup on the DOM node but captured itemId once, so a host node reused for a different file could dispatch to a stale itemId; and the settle-timer could fire after the host detached. Hold itemId in a mutable per-host entry (refreshed on re-render) and bail the settle callback when the host is no longer connected.
… flag, tidy comments
Summary
Highlight code in the desktop file viewer or a git diff and send it — with its file path and line range — straight to an agent, no copy-paste.
Both share one formatter/send path, so the agent gets the same context shape either way.
Type of Change
Testing
bun run lintbun run typecheckbun test(unit tests for capture/bound/format/dispatch + the diff line-resolver, which is also verified against the live@pierre/diffsshadow DOM)Notes
@pierre/diffs1.2.2 internals (shadowRoot.getSelection,data-line); line-level, single-file. Upstream: Feature: Expose Native Cursor Selection pierrecomputer/pierre#248.Deferred (follow-up)
launchAgentSession({kind:"chat"})); a follow-up.